package com.controller;

import com.model.User;
import com.service.UserService;
import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;

@Controller
public class IndexController implements ApplicationContextAware {
    @Resource
    UserService userService;

    @RequestMapping(value = "index")
    @ResponseBody
    public String index(){
        User user = userService.findUserById("1");
        return user.getName();
    }

    /**
     * @param applicationContext
     * @throws BeansException
     */
    @Override
    public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {

    }

    @RequestMapping(value = "test")
    public void test(String[] arr) {
        System.out.println(arr);
    }
}
